<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

	//	/* Other functions may have been omitted */
	//
	//  protected function _initTwigView()
	//  {
	//    $twigView = new ZExt_Twig(APPLICATION_PATH, APPLICATION_PATH."/modules");
	//    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper("ViewRenderer");
	//    $viewRenderer->setView($twigView);
	//
	//    return $twigView;
	//  }
	//	protected function _initModifiedFrontController()
	//	{
	//		 $this->bootstrap('FrontController');
	// $front = $this->getResource('FrontController');
	// $response = new Zend_Controller_Response_Http;
	// $response->setHeader('Content-Type',
	// 'text/html; charset=UTF-8', true);
	// $front->setResponse($response);
	//	}
	//

	/**
	 * Init Plugin System
	 */
	protected function __initPlugin()
	{
            $front = Zend_Controller_Front::getInstance();
            $front->registerPlugin(new Zend_Controller_Plugin_PutHandler());
            $front->registerPlugin(new MyPlugin());
            
            //$logger = new Zend_Application_Resource_Log();
            //Init Log plugin
            //$logconfigfilename = APP_CONFIG . DS .'log.ini';
            //$front->registerPlugin(new LoggerPlugin($logconfigfilename));
	}
	#
	/**
	* Init Document type head on each html page.
	*/
	protected function _initDoctype()
	{
		$this->bootstrap('view');
		$view = $this->getResource('view');
		$view->doctype('XHTML1_STRICT');
	}
	/**
	 *
	 * Init the view for appp
	 * @return Zend_View
	 */
	protected  function _initView()
	{
		$view = new Zend_View();
		//		$view->setEncoding('UTF-8');
		//		$view->doctype('XHTML1_STRICT');
		//		$view->headMeta()->appendHttpEquiv(
		//		 	'Content-Type', 'text/html;charset=utf-8'
		//		 	);
		//		 	$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
		//		 'ViewRenderer');
		//		 	$viewRenderer->setView($view);
		//$front = Zend_Controller_Front::getInstance();
		//$front->setView($view);
		return $view;
	}
//        protected function _initLayout()
//        {
//            $layoutconfig = new Zend_Config_Ini(APP_CONFIG .DS. "layout.ini","layout");
//            $layout = new Zend_Layout($layoutconfig);            
//        }
        protected function _initRestRoute()
	{
		$this->bootstrap('frontController');
		$frontController = Zend_Controller_Front::getInstance();
		$restRoute = new Zend_Rest_Route($frontController);
		$frontController->getRouter()->addRoute('rest', $restRoute);
	}

	protected function _initPropel()
	{
		require_once ('/propel/runtime/lib/Propel.php');
		Propel::init(APP_PATH . '/configs/propel-config.php');
	}
	protected function _initAuth()
	{
		$auth = Zend_Auth::getInstance();
		$auth->setStorage(new Zend_Auth_Storage_Session('auth', null));
                return $auth;
		//$config=array();
		//new Zend_Auth_Adapter_Http();
	}
	protected function _initAcl()
	{
		//Access control
		$acl = new Zend_Acl();
		$acl->addRole(new Zend_Acl_Role('guest'))
		->addRole(new Zend_Acl_Role('member'))
		->addRole(new Zend_Acl_Role('admin'));                
                return $acl;
	}
}